package cz.muni.fi.pb138.accountingRecords;

import java.util.Date;
import java.util.List;

/**
 * Class representing invoice, generated default getters and setters
 * @author Michal
 */
public class Invoice {
    private String id;
    private Long invoiceNumber;
    private Subject distributor;
    private Subject consumer;
    private List<Item> items;
    private PaymentType paymentType;
    private Date invoicingDate;
    private Date dueDate;
    private String bankAccount;// --IMPLIED
    private String drawer;//name and surname of person who issued invoice
    private Long variableSymbol;

    /**
     * Returns bank account
     * @return bank account in format 123456789/1234
     */
    public String getBankAccount() {
        return bankAccount;
    }

    /**
     * Sets bank account
     * @param bankAccount bank account in format 123456789/1234
     */
    public void setBankAccount(String bankAccount) {
        this.bankAccount = bankAccount;
    }

    /**
     * returns reciever of sale item
     * @return reciever of sale item
     */
    public Subject getConsumer() {
        return consumer;
    }

    /**
     * sets reciever of sale item
     * @param consumer reciever of sale item
     */
    public void setConsumer(Subject consumer) {
        this.consumer = consumer;
    }

    /**
     * returns distributor
     * @return distributor
     */
    public Subject getDistributor() {
        return distributor;
    }

    /**
     * sets distributor
     * @param distributor distributor
     */
    public void setDistributor(Subject distributor) {
        this.distributor = distributor;
    }

    /**
     * returns name of person who issued invoice
     * @return name of person who issued invoice
     */
    public String getDrawer() {
        return drawer;
    }

    /**
     * sets the name of person who issued invoice
     * @param drawer name of person who issued invoice
     */
    public void setDrawer(String drawer) {
        this.drawer = drawer;
    }

    /**
     * returns due date, date to which invoice must be payed
     * @return due date, date to which invoice must be payed
     */
    public Date getDueDate() {
        return dueDate;
    }

    /**
     * sets the due date, date to which invoice must be payed
     * @param dueDate date to which invoice must be payed
     */
    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    /**
     * returns internal ID of invoice in Database
     * @return internal ID of invoice in Database
     */
    public String getId() {
        return id;
    }

    /**
     * sets internal ID of invoice in Database
     * @param id internal ID of invoice in Database
     */
    public void setId(String id) {
        this.id = id;
    }

    /**
     * returns invoicing date, date when invoice was issued
     * @return invoicing date, date to which invoice must be payed
     */
    public Date getInvoicingDate() {
        return invoicingDate;
    }

    /**
     * sets the due date, date to which invoice must be payed
     * @param dueDate date to which invoice must be payed
     */
    public void setInvoicingDate(Date invoicingDate) {
        this.invoicingDate = invoicingDate;
    }

    /**
     * returns list of items that was sold
     * @return list of items that was sold
     */
    public List<Item> getItems() {
        return items;
    }

    /**
     * sets items of invoice that was sold
     * @param items list of items that was sold
     */
    public void setItems(List<Item> items) {
        this.items = items;
    }

    /**
     * returns type of payment, eg cash, credit card, transfer
     * @return type of payment, eg cash, credit card, transfer
     */
    public PaymentType getPaymentType() {
        return paymentType;
    }

    /**
     * Sets type of payment, eg cash, credit card, transfer
     * @param paymentType type of payment
     */
    public void setPaymentType(PaymentType paymentType) {
        this.paymentType = paymentType;
    }

    /**
     * returns variable symbol used for transfer
     * @return variabel symbol used for transfer
     */
    public Long getVariableSymbol() {
        return variableSymbol;
    }

    /**
     * sets variable symbol used for transfer
     * @param variableSymbol variable symbol used for transfer
     */
    public void setVariableSymbol(Long variableSymbol) {
        this.variableSymbol = variableSymbol;
    }

    /**
     * returns number of invoice
     * @return number of invoice
     */
    public Long getInvoiceNumber() {
        return invoiceNumber;
    }

    /**
     * sets number of invoice
     * @param invoice_number number of invoice
     */
    public void setInvoiceNumber(Long invoice_number) {
        this.invoiceNumber = invoice_number;
    }

    /**
     * Compare 2 invoices, returns true, if they have same internal ID
     * @param obj invoice that will be compared
     * @return true if invoices have same internal ID
     */
    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Invoice other = (Invoice) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 73 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "Invoice{" + "id=" + id + "invoiceNumber=" + invoiceNumber + "distributor=" + distributor + "consumer=" + consumer + "items=" + items + "paymentType=" + paymentType + "invoicingDate=" + invoicingDate + "dueDate=" + dueDate + "bankAccount=" + bankAccount + "drawer=" + drawer + "variableSymbol=" + variableSymbol + '}';
    }

}
